package com.jsyl.lwbk.web.controller.education;

import com.jsyl.lwbk.business.domain.education.ChildTrainingProgram;
import com.jsyl.lwbk.business.dto.education.ChildTrainingProgramDTO;
import com.jsyl.lwbk.business.service.education.IChildTrainingProgramService;
import com.jsyl.lwbk.common.core.controller.BaseController;
import com.jsyl.lwbk.common.core.domain.AjaxResult;
import com.jsyl.lwbk.common.core.page.TableDataInfo;
import com.jsyl.lwbk.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author jh
 * @date 2021-04-02 16:27
 * @desc 学生课程项目
 **/
@Controller
@RequestMapping("/education/childtrainingProgram")
public class ChildTrainingProgramController extends BaseController {

    private String prefix = "education/childtrainingProgram";

    @Autowired
    private IChildTrainingProgramService iChildTrainingProgramService;



    /**
     * 成绩录入(RequestType=1)
     */
    @PostMapping("/findByChildAndProjecttype")
    @ResponseBody
    public AjaxResult list(ChildTrainingProgramDTO childTrainingProgramDTO) {
        childTrainingProgramDTO.setRequestType((short)1);
        //成绩录入都是当月的训练项目
//        childTrainingProgramDTO.setTrainingProgramNumber(DateUtils.getDateYYYYMM());
        List<ChildTrainingProgram> list = iChildTrainingProgramService.findByChildAndProjecttype(childTrainingProgramDTO);
        return AjaxResult.success(list);
    }

    /**
     * 训练项目编辑查看生成项目和上月巩固项目(RequestType=2) 及查看选中的训练项目(RequestType=3)
     */
    @PostMapping("/findByChildAndProjecttypeTable")
    @ResponseBody
    public TableDataInfo findByChildAndProjecttypeTable(ChildTrainingProgramDTO childTrainingProgramDTO) {
        startPage();
        if(childTrainingProgramDTO.getRequestType() == null){
            childTrainingProgramDTO.setRequestType((short)2);
        }
        List<ChildTrainingProgram> list = iChildTrainingProgramService.findByChildAndProjecttype(childTrainingProgramDTO);
        return getDataTable(list);
    }

    /**
     * 训练项目编辑查看生成项目和上月巩固项目(RequestType=2) 及查看选中的训练项目(RequestType=3)
     */
    @PostMapping("/findByChildAndEvaluate")
    @ResponseBody
    public TableDataInfo findByChildAndEvaluate(ChildTrainingProgramDTO childTrainingProgramDTO) {
        startPage();
        List<ChildTrainingProgram> list = iChildTrainingProgramService.findByChildAndEvaluate(childTrainingProgramDTO);
        return getDataTable(list);
    }

}
